@@ -1,5 +1,13 @@
Revision history for perl module CPAN::Changes
+0.15 2011-04-11
+
+ - Handle more date/time formats during parsing
+
+0.14 2011-04-11
+
+ - Add delete_empty_groups() to Changes.pm and Release.pm (Yanick Champoux)
+
0.13 2011-04-04
- Use version.pm's LAX regex for finding versions.
@@ -28,6 +28,7 @@ t/corpus/no-leading-space-for-change.changes
t/corpus/preamble.changes
t/corpus/space-before-date.changes
t/corpus/timestamp.changes
+t/delete_empty_groups.t
t/dist-zilla-changes.t
t/read_basic.t
t/read_different-indentation.t
@@ -26,4 +26,4 @@ requires:
resources:
license: http://dev.perl.org/licenses/
repository: http://github.com/bricas/cpan-changes
-version: 0.13
+version: 0.15
@@ -81,6 +81,9 @@ METHODS
Returns all of the data as a string, suitable for saving as a Changes
file.
+ delete_empty_groups( )
+ Deletes change groups without changes in all releases.
+
DEALING WITH "NEXT VERSION" PLACEHOLDERS
In the working copy of a distribution, it's not uncommon to have a "next
release" placeholder section as the first entry of the "Changes" file.
@@ -93,6 +93,14 @@ sub delete_group {
delete $self->{ changes }->{ $_ } for @groups;
}
+sub delete_empty_groups {
+ my $self = shift;
+
+ $self->delete_group(
+ grep { ! @{ $self->changes($_) } } $self->groups
+ );
+}
+
sub serialize {
my $self = shift;
@@ -197,6 +205,10 @@ Creates an empty group under the names provided.
Deletes the groups of changes specified.
+=head2 delete_empty_groups( )
+
+Deletes all groups that don't contain any changes.
+
=head2 serialize( )
Returns the release data as a string, suitable for inclusion in a Changes
@@ -8,7 +8,7 @@ use Text::Wrap ();
use Scalar::Util ();
use version ();
-our $VERSION = '0.13';
+our $VERSION = '0.15';
my @m = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my %months = map { $m[ $_ ] => $_ + 1 } 0 .. 11;
@@ -78,8 +78,22 @@ sub load_string {
}
}
+ # RFC 2822
+ elsif ( $d
+ =~ m{\D{3}, (\d{1,2}) (\D{3}) (\d{4}) (\d\d:\d\d:\d\d) ([+-])(\d{2})(\d{2})}
+ )
+ {
+ $d = sprintf(
+ '%d-%02d-%02dT%s%s%02d:%02d',
+ $3, $changes->{ months }->{ $2 },
+ $1, $4, $5, $6, $7
+ );
+ }
+
# handle dist-zilla style, again ingoring TZ data
- elsif ( $d =~ m{(\d{4}-\d\d-\d\d) (\d\d:\d\d:\d\d) \D+} ) {
+ elsif (
+ $d =~ m{(\d{4}-\d\d-\d\d) (\d\d:\d\d(?::\d\d)?)( \D+)?} )
+ {
$d = sprintf( '%sT%sZ', $1, $2 );
}
}
@@ -203,6 +217,12 @@ sub release {
return $self->{ releases }->{ $version };
}
+sub delete_empty_groups {
+ my $self = shift;
+
+ $_->delete_empty_groups for $self->releases;
+}
+
sub serialize {
my $self = shift;
@@ -320,6 +340,10 @@ matching release object, undef is returned.
Returns all of the data as a string, suitable for saving as a Changes
file.
+=head2 delete_empty_groups( )
+
+Deletes change groups without changes in all releases.
+
=head1 DEALING WITH "NEXT VERSION" PLACEHOLDERS
In the working copy of a distribution, it's not uncommon
@@ -1,3 +1,12 @@
+0.06 Mon, 11 Apr 2011 21:40:45 -0300
+ - RFC 2822
+
+0.05 2011-04-11 15:14
+ - Similar to 0.04, without seconds
+
+0.04 2011-04-11 12:11:10
+ - Datetime w/o T or Z
+
0.03 Fri Mar 25 2011
- Yet another release
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use CPAN::Changes;
+
+my $changes = CPAN::Changes->load_string(<<'END_CHANGES');
+0.2 2012-02-01
+ [D]
+ [E]
+ - Yadah
+
+0.1 2011-01-01
+ [A]
+ - Stuff
+ [B]
+ [C]
+ - Blah
+END_CHANGES
+
+$changes->delete_empty_groups;
+
+is_deeply( [ sort( ($changes->releases)[0]->groups ) ], [ qw/ A C / ] );
+is_deeply( [ sort( ($changes->releases)[1]->groups ) ], [ 'E' ] );
+
+
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 15;
use_ok( 'CPAN::Changes' );
@@ -10,10 +10,10 @@ my $changes = CPAN::Changes->load( 't/corpus/timestamp.changes' );
isa_ok( $changes, 'CPAN::Changes' );
my @releases = $changes->releases;
-is( scalar @releases, 3, 'has 3 releases' );
+is( scalar @releases, 6, 'has 6 releases' );
-my @expected = qw( 2011-03-25T12:16:25Z 2011-03-25T12:18:36Z 2011-03-25 );
-for ( 0..2 ) {
+my @expected = qw( 2011-03-25T12:16:25Z 2011-03-25T12:18:36Z 2011-03-25 2011-04-11T12:11:10Z 2011-04-11T15:14Z 2011-04-11T21:40:45-03:00 );
+for ( 0..5 ) {
isa_ok( $releases[ $_ ], 'CPAN::Changes::Release' );
is( $releases[ $_ ]->date, $expected[ $_ ], 'date' );
}
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 16;
+use Test::More tests => 18;
use_ok( 'CPAN::Changes' );